package com.woniuxy.userassembly.dao;

import com.woniuxy.userassembly.model.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Liyfi
 * @since 2021-05-22
 */
public interface UserMapper extends BaseMapper<User> {
    @Select("select * from hotel_user where username=#{username} and password = #{password}")
    User loginByUsername(@Param("username") String username,@Param("password") String password);

    @Select("select * from hotel_user where tel=#{tel}")
    User checkOnlyTel(@Param("tel") String tel);

    @Update("update hotel_user set username=#{username} ,password=#{password},addr=#{addr},head_url=#{headUrl} where user_id=#{userId}")
    int updUser(@Param("username") String username,@Param("password") String password,@Param("addr") String addr,@Param("headUrl") String url,@Param("userId") Integer userId);

    @Update("update hotel_user set credit = credit+#{credit} where user_id = #{userId}")
    int increaseCredit(@Param("credit") Integer credit ,@Param("userId") Integer userId);

    @Update("update hotel_user set credit = credit-#{credit} where user_id = #{userId}")
    int cutBackCredit(@Param("credit") Integer credit ,@Param("userId") Integer userId);

    @Update("update hotel_user set growth = growth+#{growth} where user_id = #{userId}")
    int increaseGrowthValue(@Param("growth") Integer growth ,@Param("userId") Integer userId);



    @Select("select * from hotel_user where user_id = #{userId}")
    User selUser(Integer userId);

    @Update("update hotel_user set level = #{level} where user_id = #{userId}")
    int changeLevel(@Param("level") Integer level ,@Param("userId") Integer userId);

    @Update("update hotel_user set balance = #{balance} where user_id = #{userId}")
    int addMoney(@Param("balance") double balance,@Param("userId") int userId);





}
